<?php
namespace API\Controller;
use Think\Controller;
class UserserviceController extends Controller {
  public function getvideos(){
    	$vid=$_GET['vid'];
    	$videosModel=M('videos'); //实例化模型对象 user 表名
		$videos=$videosModel->where("vid=$vid")->select(); //查询
       /*$data['status']  = 1;
$data['content'] = 'content';*/
   /*arrayRecursive($videos, 'urlencode', true);
    $json = json_encode($videos);*/
   echo json_encode($videos);
/*$this->json_encode($videos);*/
/*$this->display();*/
/*$this->json_encode($videos);
$this->display()*/;
    }
     public function regist(){
      $user_name=$_GET['user_name'];
      $user_password=$_GET['user_password'];
      $user_tel=$_GET['user_tel'];
      $user_email=$_GET['user_email'];
      $user_picture=$_GET['user_picture'];
      $userModel=M('user');
      $data=$userModel->create();
      $map['user_name']=$user_name;
      $map['user_tel']=$user_tel;
      $count = $userModel->where($map)->getField('count(*)');
      if($count>0){
        //已经注册
        $success = '2';
        $error_code='已注册';
      }else{
        $data['user_name']=$user_name;
        $data['user_password']=$user_password;
        $data['user_tel']=$user_tel;
        $data['user_email']=$user_email;
        $data['user_picture']=$user_picture;
        $data['user_date']=date('Y-m-d H:i:s');
        $res=$userModel->data($data)->add();
        if($res){
          //注册成功
          $success='1';
          $error_code='注册成功';
        }else{
          //注册失败
          $success='0';
          $error_code='注册失败';
        }
      }
      $json=array('success' =>$success, 'error_code' =>$error_code, 'datalist' =>$datalist);
      echo json_encode($json);
    }
}